package com.mpyy.service.sales;

import com.mpyy.dao.sales.ReturnedPurchaseDaoInter;
import com.mpyy.pojo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @version 1.0
 * @Description ReturnedPurchaseServiceImpl
 * @Author YYJC
 * @Date 2022-03-07 9:19
 */
@Service(value = "returnedPurchaseService")
public class ReturnedPurchaseServiceImpl implements ReturnedPurchaseServiceInter {
    @Autowired
    @Qualifier(value = "returnedPurchaseDao")
    private ReturnedPurchaseDaoInter returnedPurchaseDaoInter;

    /**
     * 查询商品清单
     * @param saleOrderDesc
     * @return
     */
    @Override
    public List<SaleOrderDesc> searchReturnedPurchase(SaleOrderDesc saleOrderDesc) {
        return returnedPurchaseDaoInter.searchReturnedPurchase (saleOrderDesc);
    }

    /**
     * 查询仓库
     * @return
     */
    @Override
    public List<DepotInfo> searchStorehouse() {
        List<DepotInfo> depotInfos = returnedPurchaseDaoInter.searchStorehouse ( );
        return depotInfos;
    }

    /**
     * 商品批次信息
     * @param saleOrderDesc
     * @return
     */
    @Override
    public List<SaleOrderDesc> searchCommodityBatch(SaleOrderDesc saleOrderDesc) {
        return returnedPurchaseDaoInter.searchCommodityBatch (saleOrderDesc);
    }

    /**
     * 客户与客户类型查询
     * @param customerInfo
     * @return
     */
    @Override
    public List<CustomerInfo> searchCustomerInfo(CustomerInfo customerInfo) {
        return returnedPurchaseDaoInter.searchCustomerInfo (customerInfo);
    }

    /**
     * 查询经办人
     * @return
     */
    @Override
    public List<EmployeeInfo> searchEmpName() {
        return returnedPurchaseDaoInter.searchEmpName ();
    }

    /**
     * 新增数据至销售退货(service一条)
     * 修改库存数量
     * @param saleReturn
     * @param saleReturnDesc
     * @return
     */
    @Override
    public Integer updateSalesReturn(SaleReturn saleReturn, List<SaleReturnDesc> saleReturnDesc) {
        /*新增退货表*/
        Integer integer = returnedPurchaseDaoInter.updateSalesReturn (saleReturn);

        /*新增退货明细表*/
        Integer integers = returnedPurchaseDaoInter.updateSalesReturndetail (saleReturnDesc);

        /*修改库存数量*/
        Integer i = returnedPurchaseDaoInter.updateInveDescInventoryNum (saleReturnDesc);

        /*修改销售订单明细商品数量*/
        Integer i2 = returnedPurchaseDaoInter.updateSaleOrderDescNum (saleReturnDesc);

        /*新增商品变动表*/
        Integer i3 = returnedPurchaseDaoInter.updateInventoryChange (saleReturnDesc);

        return integer+integers;
    }

    /**
     * 根据客户ID查询销售订单号(原始单号)
     * @param saleOrder
     * @return
     */
    @Override
    public List<SaleOrder> searchSaleCustId(SaleOrder saleOrder) {
        return returnedPurchaseDaoInter.searchSaleCustId (saleOrder);
    }


    /**
     * 左侧类别
     *
     * @return
     */
    @Override
    public List<ProductType> searchReturnInfo() {
        return returnedPurchaseDaoInter.searchReturnInfo (null);
    }


    /**
     * 顾客退货树状图
     * @param proTypeId
     * @return
     */
    @Override
    public List<SaleOrderDesc> searchReturnTree(String proTypeId) {
        return returnedPurchaseDaoInter.searchReturnTree (proTypeId);
    }

    /**
     * 顾客退货历史
     * @param saleReturnDesc
     * @return
     */
    @Override
    public List<SaleReturn> searchReturnHistory(SaleReturnDesc saleReturnDesc) {
        return returnedPurchaseDaoInter.searchReturnHistory (saleReturnDesc);
    }

}
